<include file="header" />
<style type="text/css">
	.up_prize_choose_icon{border-color:transparent transparent #ad0610 transparent}
	.up_prize_icon{border-color:transparent transparent #000 transparent}
	.down_prize_choose_icon{border-color:#ad0610 transparent transparent transparent}
	.down_prize_icon{border-color:#000 transparent transparent transparent}
</style>
<div class="wraper">
    <div class="search-product">
        <a href="javascript:history.go(-1);" class="iconfont icon-zuozuo"></a>
        <p class="search-box"><span class="iconfont icon-search pull-left"></span><input class="pull-left" type="text" placeholder="请输入商品关键字" id="keyword" value="{BEESCRM:$keyword}"/></p>
        <a href="javascript:;" id="classify"><span class="iconfont icon-fenlei1"></span><p>分类</p></a>
    </div>
    <div class="classify-list">
		<a href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId,'order'=>'recommend','origin'=>$origin,'keyword'=>$keyword,'cate_id'=>$cate_id))}" <if condition="$order eq 'recommend' "> class="current" </if>>推荐</a>
        <a href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId,'order'=>'sale_num','origin'=>$origin,'keyword'=>$keyword,'cate_id'=>$cate_id))}" <if condition="$order eq 'sale_num' "> class="current" </if>>销量</a>
        <a href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId,'order'=>'goods_price','origin'=>$origin,'keyword'=>$keyword,'order_by'=>$order_by,'cate_id'=>$cate_id))}" <if condition="$order eq 'goods_price' "> class="current" </if>>价格<p><span class="triangle-top <if condition="$order_by eq 'asc' ">up_prize_choose_icon<else/>up_prize_icon</if>"></span><span class="triangle-bottom <if condition="$order_by eq 'desc' ">down_prize_choose_icon<else/>down_prize_icon</if>"></span></p></a>
        <a href="javascript:;"><span class="iconfont icon-fenlei"></span></a>
    </div>
    <div class="product">
        <volist name="data" id="vo">
        <a href="{BEESCRM::U('base/store/goodsdetail',array('store_id'=>$storeId,'goods_id'=>$vo['goods_id'],'origin'=>$origin))}" class="tabulation clearfix">
            <div class="tabulation-img"><div><img src="{BEESCRM:$vo['goods_thumb']}"/></div></div>
            <div class="tabulation-info">
                <p class="prize tabulation-name">{BEESCRM:$vo['goods_name']}</p>
				<p class="prize text-12">
					<if condition="$vo.picked eq 0">
						<span class="product-label">快递</span>
					<else/>
						<span class="product-label">自提</span>
					</if>
                    <if condition="$vo.other eq 1">
						<span class="product-label">厂家直营</span>
                    </if>
				</p>
                <p class="prize">
					<span class="new-prize">￥{BEESCRM:$vo['goods_price']}</span>
					<span class="sale">已售{BEESCRM:$vo['sale_num']}</span>
				</p>
            </div>
        </a>
        </volist>
    </div>
</div>
<div class="pop-classify">
    <p class="list">选择分类<span class="pull-right" id="cancel">取消</span></p>
    <volist name="cate" id="vo">
    	<a href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId, 'cate_id'=>$vo['cate_id'],'origin'=>$origin))}" <if condition="$vo['cate_id'] eq $cate_id">class="list actived"<else/>class="list"</if>>{BEESCRM:$vo['cate_name']}<span class="iconfont icon-xuanzedianjihou pull-right"></span></a>
    </volist>
</div>
<a href="javascript:void(0);" class="back-to-top"><span class="iconfont icon-fanhuidingbu"></span><p>顶部</p></a>
<include file="commonJs" />
<include file="footer" />
<script>
    $(function(){
        $('#classify').click(function(){
            $('.pop-classify').show();
        });
        $('#cancel').click(function(){
            $('.pop-classify').hide();
        });
        $('.pop-classify').on('click','p',function(){
            $(this).addClass('actived').siblings().removeClass('actived');
        })
    })
$(document).ready(function(){
	$('.icon-search').on('click',function(){
		var keyword=$('#keyword').val();
		if(keyword){
			window.location.href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId,'origin'=>$origin))}/keyword/"+keyword;
		}else{
			$.alert('error','搜索条件不能为空');
		}
	});
	
	 function getScrollTop() {
			return document.documentElement.scrollTop + document.body.scrollTop;
		}
		function setScrollTop(value) {
			if (document.documentElement.scrollTop) {
				document.documentElement.scrollTop = value;
			} else {
				document.body.scrollTop = value;
			}
		}

		$(".back-to-top").click(function(){
			var goTop = setInterval(scrollMove, 10);
			function scrollMove() {
				setScrollTop(getScrollTop() / 1.1);
				if (getScrollTop() < 1) clearInterval(goTop);
			}
		});
	
	document.onkeydown = function(e) {
	    var ev = document.all ? window.event : e;
	    if (ev.keyCode == 13) {
	    	var keyword=$('#keyword').val();
			if(keyword){
				window.location.href="{BEESCRM::U('base/store/goodsList',array('store_id'=>$storeId,'origin'=>$origin))}/keyword/"+keyword;
			}else{
				alert('搜索条件为空');
				//$.alert('error','搜索条件不能为空');
			}
	    }
	}
	
	$(document).ready(function(){
		var page = 2,
			url="{BEESCRM:$url}",
			flag = true;

		$(window).scroll(function(){
			if(($(window).scrollTop() + $(window).height() > $(document).height() - 40)){
				if(flag) {
					flag = false;
					$.ajax({
						type:"GET",
						url:url,
						data:{'page': page},
						dataType:'json',
						beforeSend:function(){
							// 显示加载时候的提示
							$('.data-loding').show();
						},
						success:function(data){
							var str ='';
							if(data.status=='S'){
								if(data.data.length > 0) {
									$('.data-loding').hide();
									$.each(data.data,function(i,k){
										str += "<a href='"+k.url+"' class='tabulation clearfix'><div class='tabulation-img'>"+
										"<img src='"+ k.goods_thumb+"'/>"+"</div><div class='tabulation-info'>"+
										"<p class='tabulation-name'>"+ k.goods_name+"</p>"+
										"<p class='prize text-12'>";
										if (k.picked == 0) {
											str += "<span class='product-label'>快递</span>";
										}else{
											str += "<span class='product-label'>自提</span>";
										}
                                        if(k.other == 1){
											str += "<span class='product-label'>厂家直营</span>";
                                        }
										str += "</p>"+
										"<p class='prize'>"+
										"<span class='new-prize'>￥"+k.goods_price+"</span>"+
										"<span class='sale'>已售"+k.sale_num+"</span>"+
										"</p></div></a>";
									});
									$(".product").append(str);
									page++;
									flag = true;
								} else {
									$('.data-loding').hide();
									flag = false;
								}
							}
						}
					});
				}
			}
		})
	})
});
</script>
